import 'package:flutter/material.dart';
import 'package:kasax_demos2/entry/data_posts_test.dart';
import 'package:kasax/utils/color_utils.dart';
import 'package:kasax_demos2/entry/entrys.dart';

class CustomerViewDemo extends StatefulWidget {
  const CustomerViewDemo({Key? key}) : super(key: key);

  @override
  _CustomerViewDemoState createState() => _CustomerViewDemoState();
}

class _CustomerViewDemoState extends State<CustomerViewDemo> {
  var gridDelegate =
      SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3);
  List<Posts> _list = PostsDatas.TEST_POSTS;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("CustomerView"),
      ),
      body: buildSingleChildScrollView(),
    );
  }

  SingleChildScrollView buildSingleChildScrollView() {
    return SingleChildScrollView(
      child: Container(
        padding: EdgeInsets.all(16),
        child: Column(children: [
          Text("CustomScrollView+SliverGrid"),
          CustomScrollView(
            physics: NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            semanticChildCount: 4,
            slivers: [
              /// Uses a [SliverGridDelegateWithMaxCrossAxisExtent] as the [gridDelegate],
              /// and a [SliverChildListDelegate] as the [delegate].
              SliverGrid(
                  delegate: SliverChildBuilderDelegate((context, index) {
                    var info = _list[index];
                    return Container(
                      alignment: Alignment.center,
                      color: Colors.teal[100 * (index % 9)],
                      child: Text(info.title),
                    );
                  }, childCount: _list.length),
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 3)),
              SliverGrid(
                delegate: SliverChildBuilderDelegate((context, index) {
                  var info = _list[index];
                  return Container(
                    alignment: Alignment.center,
                    color: Colors.lightBlue[100 * (index % 9)],
                    child: Text(info.title),
                  );
                }, childCount: _list.length, semanticIndexOffset: 2),
                gridDelegate: gridDelegate,
              ),
            ],
          ),
        ]),
      ),
    );
  }
}
